package com.yingside.collection.homework;

public class Student implements Comparable<Student>{
    private String studentName;
    private int age;
    private float score;



    @Override
    public String toString() {
        return "Student{" +
                "studentName='" + studentName + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    public Student() {
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public float getScore() {
        return score;
    }

    public void setScore(float score) {
        this.score = score;
    }

    public Student(String studentName, int age, float score) {
        this.studentName = studentName;
        this.age = age;
        this.score = score;
    }

    @Override
    public int compareTo(Student student) {
        float diff = this.getScore() - student.getScore();
        if (diff > 0){
            return 1;
        }
        else if(diff < 0){
            return -1;
        }
        else{
            int d = this.getAge() - student.getAge();
            return d;
        }
    }
}
